package com.hitqz.robot.api.business.enums;

import java.util.HashMap;
import java.util.Objects;

/**
 * 检测结果类型
 * @author wengyx
 * @date 2024/8/7
 */
public enum ResultTypeEnum {

    //0-无返回 1-浮点型 2-单个枚举 3-多个枚举 4-字符串
    NO("0", "无返回"),

    FLOAT("1", "浮点型"),

    SINGLE_ENUM("2", "单个枚举"),

    MULTI_ENUM("3", "多个枚举"),

    STRING("4", "字符串"),

    LED("5", " 数显"),


    ;

    public final static HashMap<String, String> CMD_TYPE_DES = new HashMap<>();


    static {
        for (ResultTypeEnum value : values()) {
            ResultTypeEnum.CMD_TYPE_DES.put(value.getType(), value.getDes());
        }
    }

    private final String type;

    private final String des;


    ResultTypeEnum(String flag, String des){
        this.type = flag;
        this.des = des;
    }

    public String getDes() {
        return des;
    }

    public String getType() {
        return type;
    }

    public static ResultTypeEnum fromType(String type){
        for (ResultTypeEnum value : values()) {
            if (Objects.equals(value.getType(),type)){
                return value;
            }
        }
        return NO;
    }
}
